var { deviceHelper, appHelper } = require("../helper/index");
var gUtils = require("../shizukuUtils/g/gUtils");

function goHome(appName) {
  deviceHelper.goHome();
  gUtils.sleep(5, 10);
  appHelper.open(appName);
}

Wang.main = function (appName, duration) {
  duration = duration || 10;
  var startTime = Date.now();
  while (true) {
    goHome(appName);
    gUtils.sleep(1 * 60, 3 * 60);
    var hasExec = gUtils.hasExec(startTime);
    if (hasExec > duration * 60) {
      break;
    }
  }
  toastLog("已结束：" + duration + "分钟");
};
